package com.wing.sell.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wing.sell.dao.DeliveryPlanDetailDao;
import com.wing.sell.model.entity.DeliveryPlanDetail;
import com.wing.sell.model.request.DeliveryPlanDetailForm;
import com.wing.sell.model.response.DeliveryPlanDetailVO;
import com.wing.sell.model.response.DeliveryPlanVO;
import com.wing.sell.service.DeliveryPlanDetailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 交付计划明细-ServiceImpl
 *
 * @author
 */
@Service
@Slf4j
public class DeliveryPlanDetailServiceImpl extends ServiceImpl<DeliveryPlanDetailDao, DeliveryPlanDetail> implements DeliveryPlanDetailService {


    @Override
    public int add(DeliveryPlanDetailForm deliveryPlanDetailForm) {

        //添加交付计划明细
        DeliveryPlanDetail deliveryPlanDetail =new DeliveryPlanDetail();
        CopyOptions copyOptions = CopyOptions.create()
                .setEditable(DeliveryPlanDetail.class)
                .setIgnoreError(true)
                .setIgnoreNullValue(true);
        BeanUtil.copyProperties(deliveryPlanDetailForm, deliveryPlanDetail, copyOptions);
       return baseMapper.insert(deliveryPlanDetail);
    }

    @Override
    public List<DeliveryPlanDetailVO> list4app(Map<String, Object> params) {
        return baseMapper.list4app(params);
    }

    @Override
    public Page<DeliveryPlanDetailVO> pageList4app(Page page, Map<String, Object> params) {
        List<DeliveryPlanVO> list = baseMapper.list4app(page, params);
        page.setRecords(list);
        return page;
    }

    @Override
    public DeliveryPlanDetailVO get4appById(Long id) {
        return baseMapper.get4appById(id);
    }

    @Override
    public List<DeliveryPlanDetailVO> getDeliveryPlanDetailList(Map<String, Object> params) {
        return baseMapper.getDeliveryPlanDetailList(params);
    }
}
